#ifndef LEMC_CHECKBOX_H
#define LEMC_CHECKBOX_H

#include "WindowsIncludes.h"
#include <allegro5/allegro.h>
#include <allegro5/allegro_font.h>
#include <allegro5/allegro_ttf.h>
#include <string>
#include <functional>

#include "button.h"
#include "../resourcemanager/allegro_bitmap_manager.h"
#include "../system/global.h"

/*
* Provides the functionality of a simple checkbox which can be checked or unchecked.
*/
class CheckBox : public Button
{
private:
	// Keeps track of whether the checkbox is checked or not.
	bool m_checked;

public:
	/*
	* Creates the button.
	*
	* @param id The id of the button, should be unique.
	* @param x The x position of the upper left corner of the button.
	* @param y The y position of the upper left corner of the button.
	* @param size_x Horizontal size of the button.
	* @param size_y Vertical size of the button.
	* @param action The action to trigger when the button is pressed.
	* @param graphic_up The graphic to show when the button is not pressed.
	* @param graphic_down The graphic to show when the button is pressed.
	* @param label_font The label of the font to show. 
	* @param label The label to show on the button.
	* @param label_color The color of the label on the button.
	*/
	CheckBox(std::string id, int x, int y, int size_x, int size_y, std::function<void()> action,
		std::string graphic_up = STANDARD_CHECKBOX_GRAPHIC_UNCHECKED,
		std::string graphic_down = STANDARD_CHECKBOX_GRAPHIC_CHECKED,
		ALLEGRO_FONT* label_font = NULL, std::string label = "", 
		const unsigned char label_color[3] = STANDARD_CHECKBOX_LABEL_COLOR);
	~CheckBox();

	void PrimaryMouseButtonUp(int x, int y);
	void PrimaryMouseButtonDown(int x, int y);

	void Draw();

	void set_checked(bool checked) { m_checked = checked; }
	bool checked() { return m_checked; }
};

#endif